﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2_6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // 获取当前年份并显示到textBox2
            int currentYear = DateTime.Now.Year;
            textBox2.Text = currentYear.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // 转换起始年和结束年
            int startYear = int.Parse(textBox1.Text);
            int endYear = int.Parse(textBox2.Text);
            textBox3.Text = ""; // 清空之前的结果

            // 遍历年份范围，判断闰年
            for (int year = startYear; year <= endYear; year++)
            {
                // 闰年规则：能被4整除且不能被100整除，或能被400整除
                bool isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
                if (isLeapYear)
                {
                    // 用\t分隔，实现对齐
                    textBox3.Text += year.ToString() + "\t";
                }
            }
        }
    }
}
